package com.linzelin.mapper;

import com.linzelin.pojo.SysUser;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface UserMapper {
    /*这里因为继承的Mapper和使用的注解的Mapper有冲突,所以这里使用这种方式导入*/

    /**
     * 通过用户名查询对应的字段
     */
    @Select("select * from user where username=#{username}")
    @Results({
            @Result(id = true, property = "id", column = "id"),
            @Result(property = "roles", column = "id", javaType = List.class
                    , many = @Many(select = "com.linzelin.mapper.RoleMapper.findByUid"))
    })
    SysUser findByName(String username);

}
